package development.hdk.dialogs;

import android.R;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.SearchView.OnCloseListener;
import development.hdk.mindmapfornandroid.CommonResources;
import development.hdk.mindmapfornandroid.ProcessorActivity;
import development.hdk.mindmapfornandroid.ColorAdapter;
import java.util.ArrayList;
import java.util.List;


public class DialogHandler implements OnClickListener,android.content.DialogInterface.OnClickListener
{
  public static final int DIALOG_TEXT = 1;
  public static final int DIALOG_SHAPE = 2;
  public static final int DIALOG_BACKGROUND = 3;
  public static final int DIALOG_BORDER = 4;
  public static final int DIALOG_ICON = 5;
  public static final int DIALOG_LAYOUT_BACKGROUND = 6;
  public static final int DIALOG_STYLES = 7;
  public static final int DIALOG_NEW_NODE = 8;
  private List<Integer> colorList = new ArrayList();
  public EditText editNewText;
  public EditText editText;
  private String[] icons;
  private ProcessorActivity main;
  public LinearLayout panelLayout;
  public PopupWindow panelPop;
  private String[] styles;

  public DialogHandler(ProcessorActivity paramProcessorActivity, CommonResources paramCommonResources)
  {
    this.main = paramProcessorActivity;
    String[] arrayOfString = paramProcessorActivity.getResources().getStringArray(2131034112);
    this.icons = paramProcessorActivity.getResources().getStringArray(2131034113);
    this.styles = paramProcessorActivity.getResources().getStringArray(2131034114);
    for (int i = 0; ; i++)
    {
      if (i >= arrayOfString.length)
      {
        this.panelLayout = ((LinearLayout)paramProcessorActivity.getLayoutInflater().inflate(2130903044, null));
        this.panelLayout.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
        this.panelPop = new PopupWindow(paramProcessorActivity);
        this.panelPop.setContentView(this.panelLayout);
        this.panelPop.setBackgroundDrawable(new BitmapDrawable());
        this.panelPop.setOutsideTouchable(true);
        this.panelPop.setHeight(-2);
        this.panelPop.setWidth(-2);
        //this.panelLayout.findViewById(2131165192).setOnClickListener(new DialogHandler.1(this, paramProcessorActivity));
        this.panelLayout.findViewById(2131165192).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				panelPop.dismiss();
				main.fromUI = false;
				main.showDialog(8);
				
			}
		});
        //this.panelLayout.findViewById(2131165194).setOnClickListener(new DialogHandler.2(this, paramProcessorActivity));
        this.panelLayout.findViewById(2131165194).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				panelPop.dismiss();
				main.showDialog(1);
			}
		});
        //this.panelLayout.findViewById(2131165198).setOnClickListener(new DialogHandler.3(this, paramProcessorActivity));
        this.panelLayout.findViewById(2131165198).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				panelPop.dismiss();
				main.showDialog(3);
			}
		});
        //this.panelLayout.findViewById(2131165200).setOnClickListener(new DialogHandler.4(this, paramProcessorActivity));
        this.panelLayout.findViewById(2131165200).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				panelPop.dismiss();
				main.showDialog(4);
			}
		});
        //this.panelLayout.findViewById(2131165202).setOnClickListener(new DialogHandler.5(this, paramProcessorActivity));
        this.panelLayout.findViewById(2131165202).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				panelPop.dismiss();
				main.showDialog(5);
			}
		});
        //this.panelLayout.findViewById(2131165196).setOnClickListener(new DialogHandler.6(this, paramProcessorActivity));
        this.panelLayout.findViewById(2131165196).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				panelPop.dismiss();
				main.showDialog(2);
			}
		});
        //this.panelLayout.findViewById(2131165204).setOnClickListener(new DialogHandler.7(this, paramProcessorActivity));*/
        this.panelLayout.findViewById(2131165204).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				panelPop.dismiss();
				main.panelDeleteNode();
			}
		});
        return;
      }
      this.colorList.add(Integer.valueOf(Color.parseColor(arrayOfString[i])));
    }
  }

  private void setStyle(int paramInt)
  {
    TypedArray localTypedArray = this.main.getResources().obtainTypedArray(this.main.getResources().getIdentifier(this.styles[paramInt], "array", this.main.getPackageName()));
    int i = localTypedArray.getInt(0, 1);
    int j = localTypedArray.getInt(1, Color.parseColor("#000000"));
    int k = localTypedArray.getInt(2, Color.parseColor("#ffffff"));
    int m = localTypedArray.getInt(3, Color.parseColor("#e9e9e9"));
    this.main.setStyle(i, k, j, m);
  }

  public Dialog createDialog(int paramInt)
  {
    AlertDialog localAlertDialog;
    switch (paramInt)
    {
    default:
      localAlertDialog = null;
    case 1:
    case 8:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      while (true)
      {
        //
        AlertDialog.Builder localBuilder8 = new AlertDialog.Builder(this.main);
        localBuilder8.setTitle("Text");
        localBuilder8.setIcon(0);
        RelativeLayout localRelativeLayout2 = (RelativeLayout)this.main.getLayoutInflater().inflate(2130903045, null);
        this.editText = ((EditText)localRelativeLayout2.findViewById(2131165205));
        localBuilder8.setView(localRelativeLayout2);
        localBuilder8.setNegativeButton("Cancel", null);
        //DialogHandler.8 local8 = new DialogHandler.8(this);
        localBuilder8.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				main.setNodeText(editText.getText().toString());
			}
		} );
        localAlertDialog = localBuilder8.create();
        localAlertDialog.getWindow().setSoftInputMode(5);
        AlertDialog.Builder localBuilder7 = new AlertDialog.Builder(this.main);
        localBuilder7.setTitle("Text");
        localBuilder7.setIcon(0);
        RelativeLayout localRelativeLayout1 = (RelativeLayout)this.main.getLayoutInflater().inflate(2130903043, null);
        this.editNewText = ((EditText)localRelativeLayout1.findViewById(2131165190));
        localBuilder7.setView(localRelativeLayout1);
        localBuilder7.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				main.addNode(editText.getText().toString());
				
			}
		});
        localBuilder7.setNegativeButton("Cancel", null);
       // DialogHandler.9 local9 = new DialogHandler.9(this);
        /*localBuilder7.setPositiveButton("OK", new OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				main.addNode(editText.getText().toString());
			}
		});*/
        
        localAlertDialog = localBuilder7.create();
        localAlertDialog.getWindow().setSoftInputMode(5);
        CharSequence[] arrayOfCharSequence2 = new CharSequence[5];
        arrayOfCharSequence2[0] = "Rectangle";
        arrayOfCharSequence2[1] = "Rounded rectangle";
        arrayOfCharSequence2[2] = "Oval";
        arrayOfCharSequence2[3] = "Circle";
        arrayOfCharSequence2[4] = "No border";
        AlertDialog.Builder localBuilder6 = new AlertDialog.Builder(this.main);
        localBuilder6.setIcon(0);
        localBuilder6.setTitle("Shape");
        localBuilder6.setNegativeButton("Cancel", null);
        //DialogHandler.10 local10 = new DialogHandler.10(this);
        localBuilder6.setItems(arrayOfCharSequence2, new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				switch (which)
			    {
			    default:
			    case 0:
			    	main.setNodeShape(0);
			    case 1:
			    	 main.setNodeShape(1);
			    case 2:
			    	main.setNodeShape(2);
			    case 3:
			    	main.setNodeShape(3);
			    case 4:
			    	main.setNodeShape(4);
			    }
			  }
			});
        localAlertDialog = localBuilder6.create();
        AlertDialog.Builder localBuilder5 = new AlertDialog.Builder(this.main);
        localBuilder5.setTitle("Background Color");
        localBuilder5.setIcon(0);
        LinearLayout localLinearLayout4 = (LinearLayout)this.main.getLayoutInflater().inflate(2130903041, null);
        GridView localGridView4 = (GridView)localLinearLayout4.findViewById(2131165187);
        localGridView4.setAdapter(new ColorAdapter(this.main));
        localBuilder5.setView(localLinearLayout4);
        localBuilder5.setNegativeButton("Cancel", null);
        //DialogHandler.11 local11 = new DialogHandler.11(this);
        //localGridView4.setOnItemClickListener(local11);
        localAlertDialog = localBuilder5.create();
        AlertDialog.Builder localBuilder4 = new AlertDialog.Builder(this.main);
        localBuilder4.setTitle("Border Color");
        localBuilder4.setIcon(0);
        LinearLayout localLinearLayout3 = (LinearLayout)this.main.getLayoutInflater().inflate(2130903041, null);
        GridView localGridView3 = (GridView)localLinearLayout3.findViewById(2131165187);
        localGridView3.setAdapter(new ColorAdapter(this.main));
        localBuilder4.setView(localLinearLayout3);
        localBuilder4.setNegativeButton("Cancel", null);
        //DialogHandler.12 local12 = new DialogHandler.12(this);
        //localGridView3.setOnItemClickListener(local12);
        localAlertDialog = localBuilder4.create();
        AlertDialog.Builder localBuilder3 = new AlertDialog.Builder(this.main);
        localBuilder3.setTitle("Icon");
        localBuilder3.setIcon(0);
        LinearLayout localLinearLayout2 = (LinearLayout)this.main.getLayoutInflater().inflate(2130903042, null);
        GridView localGridView2 = (GridView)localLinearLayout2.findViewById(2131165188);
        //localGridView2.setAdapter(new IconAdapter(this.main));
        localBuilder3.setView(localLinearLayout2);
        //DialogHandler.13 local13 = new DialogHandler.13(this);
        //localBuilder3.setNegativeButton("Cancel", local13);
        //DialogHandler.14 local14 = new DialogHandler.14(this);
        //localBuilder3.setNeutralButton("No icon", local14);
        //DialogHandler.15 local15 = new DialogHandler.15(this);
        //localGridView2.setOnItemClickListener(local15);
        localAlertDialog = localBuilder3.create();
        AlertDialog.Builder localBuilder2 = new AlertDialog.Builder(this.main);
        localBuilder2.setTitle("Background color");
        localBuilder2.setIcon(0);
        LinearLayout localLinearLayout1 = (LinearLayout)this.main.getLayoutInflater().inflate(2130903041, null);
        GridView localGridView1 = (GridView)localLinearLayout1.findViewById(2131165187);
        localGridView1.setAdapter(new ColorAdapter(this.main));
        localBuilder2.setView(localLinearLayout1);
        localBuilder2.setNegativeButton("Cancel", null);
        //DialogHandler.16 local16 = new DialogHandler.16(this);
        //localGridView1.setOnItemClickListener(local16);
        localAlertDialog = localBuilder2.create();
      }
    case 7:
    }
    CharSequence[] arrayOfCharSequence1 = new CharSequence[this.styles.length];
    Resources localResources = this.main.getResources();
    for (int i = 0; ; i++)
    {
      if (i >= this.styles.length)
      {
        AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(this.main);
        localBuilder1.setTitle("Styles");
        localBuilder1.setIcon(0);
        //DialogHandler.17 local17 = new DialogHandler.17(this);
        //localBuilder1.setItems(arrayOfCharSequence1, local17);
        localBuilder1.setNegativeButton("Cancel", null);
        localAlertDialog = localBuilder1.create();
        break;
      }
      arrayOfCharSequence1[i] = localResources.obtainTypedArray(this.main.getResources().getIdentifier(this.styles[i], "array", this.main.getPackageName())).getText(4);
    }
    return localAlertDialog;
  }

@Override
public void onClick(View v) {
	// TODO Auto-generated method stub
	
}

@Override
public void onClick(DialogInterface dialog, int which) {
	// TODO Auto-generated method stub
	
}
}

/* Location:           D:\APKtoJava_RC2\tools\classes-dex2jar.jar
 * Qualified Name:     com.qdvsoftworks.schematicmind.dialogs.DialogHandler
 * JD-Core Version:    0.6.0
 */